package day04;

import day04.utils.C3P0Utils;
import org.junit.Test;

import java.sql.Connection;
import java.sql.PreparedStatement;

public class Demo01C3P0 {
    @Test
    public void insert() throws Exception {
        //获取连接
        Connection connection = C3P0Utils.getConnection();
        //准备sql
        String sql = "insert into category (cname) values (?)";
        //获取执行平台
        PreparedStatement pst = connection.prepareStatement(sql);
        pst.setObject(1,"蔬菜");
        //执行sql
        pst.executeUpdate();
        //关闭资源
        C3P0Utils.close(connection,pst,null);
    }
}
